<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
    <th:block th:include="include :: header('员工工资详情')" />
</head>
<body class="gray-bg">
<div style="background-color: white">
    <a class="btn btn-info btn-outline visible-xs-block" href="#" onclick="$.modal.closeTab()">返&nbsp;回</a>
</div>
     <div class="container-div" >
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="formId" th:object="${userId}">
                    <div class="select-list">
                        <ul>
                            <li>
                                <input type="hidden" name="sName" th:value="${userId}"/>
                            </li>
                            <li class="select-time" id="s">
                                <label>工资日期：</label>
                                <input type="text" class="time-input" id="startTime" placeholder="开始时间" name="params[beginSDate]"/>
                                <span>-</span>
                                <input type="text" class="time-input" id="endTime" placeholder="结束时间" name="params[endSDate]"/>
                            </li>
                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
<!--                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>-->
                            </li>
                        </ul>
                    </div>
                </form>
            </div>
            <div class="btn-group-sm" id="toolbar" role="group" >
<!--                <a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="system:salary:add">-->
<!--                    <i class="fa fa-plus"></i> 添加-->
<!--                </a>-->
<!--                <a class="btn btn-primary single disabled" onclick="$.operate.edit()" shiro:hasPermission="system:salary:edit">-->
<!--                    <i class="fa fa-edit"></i> 修改-->
<!--                </a>-->
<!--                <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="system:salary:remove">-->
<!--                    <i class="fa fa-remove"></i> 删除-->
<!--                </a>-->
<!--                <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="system:salary:export">-->
<!--                    <i class="fa fa-download"></i> 导出-->
<!--                </a>-->
            </div>
            <div class="col-sm-12 select-table table-bordered">
                <table id="bootstrap-table"style="color: black;font-size: 15px" data-mobile-responsive="true"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var userid=[[*{userId}]]
        var editFlag = [[${@permission.hasPermi('system:salary:edit')}]];
        var removeFlag = [[${@permission.hasPermi('system:salary:remove')}]];
        var detailFlag = [[${@permission.hasPermi('system:salary:detail')}]];
        var exportFlag = [[${@permission.hasPermi('system:salary:exports')}]];
        // 获取数据字典数据listsBalances
        var sStatuss = [[${@dict.getType('salary_status')}]];
        var prefix = ctx + "system/salary";
               $(function() {
                   var options = {
                       url: prefix + "/listsBalances",
                       // exportUrl: prefix + "/export",
                       method: 'post',
                       sidePagination: "server",
                       showFooter:true,
                       // showSearch:true,
                       // Search:true,
                       showColumns: false,
                       onLoadSuccess: onLoadSuccess,
                       contentType: "application/x-www-form-urlencoded",
                       queryParams: {
                           sName:userid
                       },
                       rowStyle:{
                           css:{"background":"lightyellow"}
                       },
                       columns: [
                           {
                               // title:'序号',
                               formatter(value, row, index){
                                   return $.table.serialNumber(index);
                               }
                           },
                           {
                               field: "sId",
                               title: '员工工资',
                               visible: false
                           },
                           {
                               //field: 'sMoney',
                               title: '员工工资',
                               formatter: function(value, row, index) {
                                   var actions = [];
                                   actions.push('￥'+row.sMoney);
                                   return actions.join('');
                               },
                               footerFormatter: function(value){
                                   var sum = 0;
                                   for (var i in value) {
                                       sum += parseFloat(value[i].sMoney)
                                   }
                                   return "总工资: ￥"+sum;
                               }
                           },
                           {
                               field : 'sBalance',
                               title : '工资下发金额',
                               formatter: function(value, row, index) {
                                   var actions = [];
                                   actions.push('￥'+row.sBalance);
                                   return actions.join('');
                               },
                               footerFormatter: function(value){
                                   var sum = 0;
                                   for (var i in value) {
                                       sum += parseFloat(value[i].sBalance)
                                   }
                                   return "总下发额: ￥"+sum;
                               }
                               // footerFormatter: function(value){
                               //     var sum =0;
                               //     for (var i in value) {
                               //         if(value[i]==null){
                               //             value[i]=0
                               //         }
                               //         sum += parseFloat(value[i].sBalance)
                               //     }
                               //     if(sum==0){
                               //         return "该员工总下发工资: ￥"+0;
                               //     }else if(sum==null){
                               //         return "该员工总下发工资: ￥"+0;
                               //     } else{
                               //         return "该员工总下发工资: ￥"+sum;
                               //     }
                               // }
                           },
                           {
                               field: 'sStatus',
                               title: '下发状态 ',
                               align: "center",
                               formatter: function(value, row, index) {
                                   return $.table.selectDictLabel(sStatuss, value);
                               }
                           },
                           {
                               //field : 'sDate',
                               title : '工资日期',
                               formatter: function(value, row, index) {
                                   var actions = [];
                                   if(row.sDate==null){
                                       actions.push('未设置工资日期');
                                       return actions.join('');
                                   }else{
                                       actions.push(row.sDate);
                                       return actions.join('');
                                   }
                               }
                           },
                           {
                               title: '操作',
                               align: 'center',
                               formatter: function (value, row, index) {
                                   var actions = [];
                                   actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="authRole(\'' + row.sId + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                                   actions.push('<a class="btn btn-info btn-xs ' + detailFlag + '" href="javascript:void(0)" onclick="detail(\'' + row.sId + '\')"><i class="fa fa-search"></i>下发</a> ');
                                   // actions.push('<a class="btn btn-warning ' + exportFlag + '" href="javascript:void(0)" onclick="$.table.exportExcel(\'' + row.sId + '\')"><i class="fa fa-download"></i>下发</a> ');
                                   return actions.join('');
                               }
                           }]
                   };
                   $.table.init(options);
               });

        /* 财务管理-修改 */
        function authRole(sId) {
            var url = prefix + '/edit/' + sId;
            $.modal.openFull("修改", url);
        }
        /* 财务管理-下发工资 */
        function detail(sId) {
            var url = prefix + '/detail/' + sId;
            $.modal.openFull("下发", url);
        }
        function onLoadSuccess() {
            $(".fixed-table-body").on("scroll",function(){
                var sl=this.scrollLeft;
                $(this).next()[0].scrollLeft = sl;
            })
        }
    </script>
</body>
</html>